package com.ziq.baselib

import android.content.Context
import android.content.Intent
import android.widget.TextView
import com.ziq.base.view.recycleview.BaseMultiViewHolder
import com.ziq.base.view.recycleview.adapter.ListMultiAdapter
import com.ziq.baselib.MainActivity.DemoListItem

class MainRecycleViewAdapter :
    ListMultiAdapter<DemoListItem?> {
    constructor(context: Context?) : super(context) {}
    constructor(context: Context?, data: List<DemoListItem?>?) : super(context, data) {}

    override fun getItemLayoutRes(): Int {
        return R.layout.item_main
    }

    override fun bindDataViewHolder(holder: BaseMultiViewHolder, position: Int) {
        val item = getItem(position)
        val title = holder.getViewById<TextView>(R.id.title)
        title.text = item!!.name
        holder.itemView.setOnClickListener { v ->
            val intent = Intent()
            intent.setClass(v.context, item.cls)
            v.context.startActivity(intent)
        }
    }
}